let jwt = require('jsonwebtoken');


const jwtOperation = {
    salt: 'thisIsTheTokenGeneration',
    signToken(userData) {
        return jwt.sign(userData, this.salt, {expiresIn: '1days'})
    },
    verifyToken(token) {
        try {
            let data = jwt.verify(token, this.salt)
            return {
                data: data,
                code: 1
            }
        } catch (e) {
            console.info(e)
            return {
                code: 401
            }
        }
    }
}

module.exports = jwtOperation